package com.lancoo.edu.platform.operation.commons.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 分页返回结果
 * @author pky
 */
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PageResult<T> extends BaseResult {
    private int code = 200;
    private long total;
    private String msg = "success";
    private T data;

    /**
     * 构建多笔数据响应结果
     *
     * @param total       总条数
     * @param attribute domain实体
     */
    public PageResult(long total, T attribute) {
        this.total = total;
        createQueryBean(attribute);
    }

    /**
     * 创建返回结果实体数据
     *
     * @param attribute 数据
     */
    private void createQueryBean(T attribute) {
        if (data == null) {
            data = attribute;
        }
    }


}
